package net.androidstudy.koreabeach;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;



public class KoreaAreaName extends ListActivity implements OnItemClickListener{

	String [] areaName={"서울시","경기도","충청북도","충청남도","전라북도",
			"전라남도", "경상북도","경상남도","제주도","영정도","강원도"};
	String [] areaengName={"seoul","gyeonggi","chungbuk","choongchungnamdo", "jeonbuk",
			"jeonnam","gyeongbuk","kyungsangnamdo","Jeju","youngjongdo","kangwondo"};
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		//데이터 준비
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, areaName);// ArrayAdapter 생성
		
		//리스트스뷰에 데이터 붙임
		setListAdapter(adapter);
		
		//리스트뷰객체 생성
		ListView lv = getListView();
		
		//리스트뷰에 이벤트 부착
		lv.setOnItemClickListener(this);
	}
	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position,
			long id) {
		
		Intent intent = new Intent().setClass(KoreaAreaName.this, KoreaAreaBeach.class);
		
		// 새로운 액티비티를 띄우면서 동시에 데이터를 넘겨줌		
		intent.putExtra("areaname", areaengName[position]);
	
		//새로운 화면을 띄우시오
		startActivity(intent);
		
	}
}
